package controller;

import java.io.IOException;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


/**
 * Primary-entry point in the MIDlet. This starts up the controller which in turns starts up all
 * other associated processes.
 *
 * @author rhaq
 * @version 1.00 2009-05-02 Initial submission.
 */
public class DrugWarsMidlet extends MIDlet
{
	/* (non-Javadoc)
	 * @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
	 */
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException
	{
	}


	/**
	 * Forces the JVM to perform memory garbage collection and shuts down the MIDlet.
	 */
	public void exit()
	{
		System.gc();

		try
		{
			destroyApp(false);
		}
		catch (MIDletStateChangeException ex)
		{
			ex.printStackTrace();
		}

		notifyDestroyed();
	}


	/* (non-Javadoc)
	 * @see javax.microedition.midlet.MIDlet#pauseApp()
	 */
	protected void pauseApp()
	{
	}


	/* (non-Javadoc)
	 * @see javax.microedition.midlet.MIDlet#startApp()
	 */
	protected void startApp() throws MIDletStateChangeException
	{
		try
		{
			new Controller(this);
		}

		catch (IOException ex)
		{
			ex.printStackTrace();
			this.exit();
		}
	}
}